<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Money_mdl extends MY_Model {

    public function __construct() {
        parent::__construct();
        $this->table = 'money';
    }

    /**
     * 向money添加实际结算价格
     * @param $order_id     订单表ID
     * @param $price        订单价格
     * @param $actual_price 实际结算价格
     * @param $uid          用户ID， 默认为当前用户
     */
    public function add_money($order_id,$price,$actual_price,$uid=''){
        $uid = empty($uid) ? $_SESSION['user']['id'] : $uid;
        $data = array(
            'user_id' => $uid,
            'actual_price' => $actual_price,
            'price' => $price,
            'order_id' => $order_id,
            'create_time' => $_SERVER['REQUEST_TIME'],
            'balance' => $price-$actual_price,
            'status' => '2'
        );
        return $this->create($data);
    }

}

/* End of file Money_mdl.php */
/* Location: ./application/models/Money_mdl.php */